package com.ruoyi.zikao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zikao.domain.ZikaoOccupation;
import com.ruoyi.zikao.service.IZikaoOccupationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 自考职业代码Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@Api(tags = "自考-职业信息管理")
@RestController
@RequestMapping("/zikao/occupation")
public class ZikaoOccupationController extends BaseController
{
    @Autowired
    private IZikaoOccupationService zikaoOccupationService;


    @GetMapping("/all")
        @ApiOperation("自考职业信息管理 - all")
    public AjaxResult all()
    {
        List<ZikaoOccupation> list = zikaoOccupationService.selectZikaoOccupationAll();
        return AjaxResult.success(list);
    }


    /**
     * 查询自考职业代码列表
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:list')")
    @GetMapping("/list")
        @ApiOperation("自考职业信息管理 - 分页查询列表")
    public TableDataInfo list(ZikaoOccupation zikaoOccupation)
    {
        startPage();
        List<ZikaoOccupation> list = zikaoOccupationService.selectZikaoOccupationList(zikaoOccupation);
        return getDataTable(list);
    }


    /**
     * 导出自考职业代码列表
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:export')")
    @Log(title = "自考职业代码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("自考职业信息管理 - 导出数据")
    public void export(HttpServletResponse response, ZikaoOccupation zikaoOccupation)
    {
        List<ZikaoOccupation> list = zikaoOccupationService.selectZikaoOccupationList(zikaoOccupation);
        ExcelUtil<ZikaoOccupation> util = new ExcelUtil<ZikaoOccupation>(ZikaoOccupation.class);
        util.exportExcel(response, list, "自考职业代码数据");
    }

    /**
     * 获取自考职业代码详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:query')")
    @GetMapping(value = "/{code}")
        @ApiOperation("自考职业信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(zikaoOccupationService.selectZikaoOccupationByCode(code));
    }

    /**
     * 新增自考职业代码
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:add')")
    @Log(title = "自考职业代码", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("自考职业信息管理 - 新增数据")
    public AjaxResult add(@RequestBody ZikaoOccupation zikaoOccupation)
    {
        return toAjax(zikaoOccupationService.insertZikaoOccupation(zikaoOccupation));
    }

    /**
     * 修改自考职业代码
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:edit')")
    @Log(title = "自考职业代码", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("自考职业信息管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZikaoOccupation zikaoOccupation)
    {
        return toAjax(zikaoOccupationService.updateZikaoOccupation(zikaoOccupation));
    }

    /**
     * 删除自考职业代码
     */
    //@PreAuthorize("@ss.hasPermi('zikao:occupation:remove')")
    @Log(title = "自考职业代码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
        @ApiOperation("自考职业信息管理 - 删除数据")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(zikaoOccupationService.deleteZikaoOccupationByCodes(codes));
    }
}
